//
//  LKSportGPSButton.m
//  SportDemo
//
//  Created by Lukj on 2017/4/30.
//  Copyright © 2017年 lukj. All rights reserved.
//

#import "LKSportGPSButton.h"
#import "LKSportTrack.h"
@implementation LKSportGPSButton

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeGPSStateNote:) name:@"LKSprotGPSStateChangeNote" object:nil];
}

//  更新GPS信息后调用
- (void)didChangeGPSStateNote:(NSNotification *)note {
    
    SportMapGPSState state = [note.userInfo[@"LKSprotGPSStateChangeNoteGPSStateKey"] unsignedIntegerValue];
    
    NSString *content;
    NSString *imgName;
    switch (state) {
        case SportMapGPSStateDisconnect: {
            
            content = @" GPS已断开 ";
            
            imgName = (_isTrackBtn) ? @"ic_sport_gps_map_disconnect" : @"ic_sport_gps_disconnect";
        }
            break;
        case SportMapGPSStateBad: {
            
            content = @" 请绕开高楼大厦 ";
            imgName = (_isTrackBtn) ? @"ic_sport_gps_map_connect_1" : @"ic_sport_gps_connect_1";
        }
            break;
        case SportMapGPSStateNormal: {
            
            content = nil;
            imgName = (_isTrackBtn) ? @"ic_sport_gps_map_connect_2" : @"ic_sport_gps_connect_2";
        }
            break;
        case SportMapGPSStateGood: {
            
            content = nil;
            imgName = (_isTrackBtn) ? @"ic_sport_gps_map_connect_3" : @"ic_sport_gps_connect_3";
        }
            break;
        default:
            break;
    }
    
    [self setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
    [self setTitle:content forState:UIControlStateNormal];
    
}


@end
